PROJECT = prj1

COURSE = cs551s10

TARGET = $(PROJECT)

#Human generated files (should be submitted).
SRC_FILES = \
  main.c \
  fns.h \
  fns.c \
  trapezoidal.h \
  trapezoidal.c \
  Makefile \
  README

#Object files.
OBJS = \
  main.o fns.o trapezoidal.o

CC = gcc
COURSE_DIR = $$HOME/$(COURSE)
INCLUDE_DIR = $(COURSE_DIR)/include
LIB_DIR = $(COURSE_DIR)/lib
CFLAGS = -g -Wall --std=c99 -I $(INCLUDE_DIR)



#This target builds the main executable for the project.
all:		$(TARGET)

$(TARGET):  	$(OBJS)
		$(CC) -L $(LIB_DIR) $(OBJS) -l$(COURSE) -lm -o $@

trapezoidal-test:	trapezoidal-test.o fns.o
			$(CC) -L $(LIB_DIR) trapezoidal-test.o fns.o \
                    	  -l$(COURSE) -lm -o $@

trapezoidal-test.o: trapezoidal.c trapezoidal.h
			$(CC) -c $(CFLAGS) -D TRAPEZOIDAL_TEST $< -o $@

#Removes all objects and executables.
clean:
		rm -f $(OBJS) $(TARGET)

#This target makes a archive containing all the project source files,
#suitable for submission.
submit:		$(SRC_FILES)
		tar -cvf $(PROJECT).tar $(SRC_FILES)
		gzip $(PROJECT).tar

#This target outputs dependencies of all C files on stdout.  The output can
#then be edited and cut-and-pasted into this Makefile.
DEPEND:
		$(CC) -MM -I $(INCLUDE_DIR) *.c

#Automatically produced dependencies pasted in from output of 'make DEPEND'.
fns.o: fns.c fns.h
main.o: main.c fns.h trapezoidal.h 
trapezoidal.o: trapezoidal.c trapezoidal.h


